home *** CD-ROM | disk | FTP | other *** search
/ American Osteopathic Ass…tion Yearbook 2005 & 2006 / American Osteopathic Association Yearbook 2005 & 2006.iso / mac / app / macfs.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2004-07-22  |  12.0 KB  |  202 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.3)
  3.  
  4. '''macfs - Pure Python module designed to be backward compatible with
  5. macfs and MACFS.
  6. '''
  7. import sys
  8. import struct
  9. import Carbon.Res as Carbon
  10. import Carbon.File as Carbon
  11. import warnings
  12. warnings.warn('macfs is deprecated, use Carbon.File, Carbon.Folder or EasyDialogs', DeprecationWarning, stacklevel = 2)
  13. sys.modules['MACFS'] = sys.modules[__name__]
  14. from Carbon.Files import *
  15. from Carbon.Folders import *
  16. READ = 1
  17. WRITE = 2
  18. smAllScripts = -3
  19. import time
  20. if time.gmtime(0)[0] == 1970:
  21.     _EPOCHCONVERT = -((1970 - 1904) * 365 + 17) * 24 * 60 * 60 + 0x100000000L
  22.     
  23.     def _utc2time(utc):
  24.         t = utc[1] + _EPOCHCONVERT
  25.         return int(t)
  26.  
  27.     
  28.     def _time2utc(t):
  29.         t = int(t) - _EPOCHCONVERT
  30.         if t < -2147483647:
  31.             t = t + 0x10000000L
  32.         
  33.         return (0, int(t), 0)
  34.  
  35. else:
  36.     
  37.     def _utc2time(utc):
  38.         t = utc[1]
  39.         if t < 0:
  40.             t = t + 0x100000000L
  41.         
  42.         return t
  43.  
  44.     
  45.     def _time2utc(t):
  46.         if t > 2147483647:
  47.             t = t - 0x100000000L
  48.         
  49.         return (0, int(t), 0)
  50.  
  51. error = Carbon.File.Error
  52.  
  53. class FSSpec(Carbon.File.FSSpec):
  54.     
  55.     def as_fsref(self):
  56.         return FSRef(self)
  57.  
  58.     
  59.     def NewAlias(self, src = None):
  60.         return Alias(Carbon.File.NewAlias(src, self))
  61.  
  62.     
  63.     def GetCreatorType(self):
  64.         finfo = self.FSpGetFInfo()
  65.         return (finfo.Creator, finfo.Type)
  66.  
  67.     
  68.     def SetCreatorType(self, ctor, tp):
  69.         finfo = self.FSpGetFInfo()
  70.         finfo.Creator = ctor
  71.         finfo.Type = tp
  72.         self.FSpSetFInfo(finfo)
  73.  
  74.     
  75.     def GetFInfo(self):
  76.         return self.FSpGetFInfo()
  77.  
  78.     
  79.     def SetFInfo(self, info):
  80.         return self.FSpSetFInfo(info)
  81.  
  82.     
  83.     def GetDates(self):
  84.         catInfoFlags = kFSCatInfoCreateDate | kFSCatInfoContentMod | kFSCatInfoBackupDate
  85.         (catinfo, d1, d2, d3) = FSRef(self).FSGetCatalogInfo(catInfoFlags)
  86.         cdate = catinfo.createDate
  87.         mdate = catinfo.contentModDate
  88.         bdate = catinfo.backupDate
  89.         return (_utc2time(cdate), _utc2time(mdate), _utc2time(bdate))
  90.  
  91.     
  92.     def SetDates(self, cdate, mdate, bdate):
  93.         catInfoFlags = kFSCatInfoCreateDate | kFSCatInfoContentMod | kFSCatInfoBackupDate
  94.         catinfo = Carbon.File.FSCatalogInfo(createDate = _time2utc(cdate), contentModDate = _time2utc(mdate), backupDate = _time2utc(bdate))
  95.         FSRef(self).FSSetCatalogInfo(catInfoFlags, catinfo)
  96.  
  97.  
  98.  
  99. class FSRef(Carbon.File.FSRef):
  100.     
  101.     def as_fsspec(self):
  102.         return FSSpec(self)
  103.  
  104.  
  105.  
  106. class Alias(Carbon.File.Alias):
  107.     
  108.     def GetInfo(self, index):
  109.         return self.GetAliasInfo(index)
  110.  
  111.     
  112.     def Update(self, *args):
  113.         pass
  114.  
  115.     
  116.     def Resolve(self, src = None):
  117.         (fss, changed) = self.ResolveAlias(src)
  118.         return (FSSpec(fss), changed)
  119.  
  120.  
  121. from Carbon.File import FInfo
  122. FSSpecType = FSSpec
  123. FSRefType = FSRef
  124. AliasType = Alias
  125. FInfoType = FInfo
  126.  
  127. def ResolveAliasFile(fss, chain = 1):
  128.     (fss, isdir, isalias) = Carbon.File.ResolveAliasFile(fss, chain)
  129.     return (FSSpec(fss), isdir, isalias)
  130.  
  131.  
  132. def RawFSSpec(data):
  133.     return FSSpec(rawdata = data)
  134.  
  135.  
  136. def RawAlias(data):
  137.     return Alias(rawdata = data)
  138.  
  139.  
  140. def FindApplication(*args):
  141.     raise NotImplementedError, 'FindApplication no longer implemented'
  142.  
  143.  
  144. def NewAliasMinimalFromFullPath(path):
  145.     return Alias(Carbon.File.NewAliasMinimalFromFullPath(path, '', ''))
  146.  
  147. from Carbon.Folder import FindFolder
  148. _curfolder = None
  149.  
  150. def StandardGetFile(*typelist):
  151.     '''Ask for an input file, optionally specifying 4-char file types that are
  152.     allowable'''
  153.     return PromptGetFile('', *typelist)
  154.  
  155.  
  156. def PromptGetFile(prompt, *typelist):
  157.     '''Ask for an input file giving the user a prompt message. Optionally you can
  158.     specifying 4-char file types that are allowable'''
  159.     import EasyDialogs
  160.     warnings.warn('macfs.StandardGetFile and friends are deprecated, use EasyDialogs.AskFileForOpen', DeprecationWarning, stacklevel = 2)
  161.     if not typelist:
  162.         typelist = None
  163.     
  164.     fss = EasyDialogs.AskFileForOpen(message = prompt, wanted = FSSpec, typeList = typelist, defaultLocation = _handleSetFolder())
  165.     return (fss, not (fss is None))
  166.  
  167.  
  168. def StandardPutFile(prompt, default = None):
  169.     '''Ask the user for an output file, with a prompt. Optionally you cn supply a
  170.     default output filename'''
  171.     import EasyDialogs
  172.     warnings.warn('macfs.StandardGetFile and friends are deprecated, use EasyDialogs.AskFileForOpen', DeprecationWarning, stacklevel = 2)
  173.     fss = EasyDialogs.AskFileForSave(wanted = FSSpec, message = prompt, savedFileName = default, defaultLocation = _handleSetFolder())
  174.     return (fss, not (fss is None))
  175.  
  176.  
  177. def SetFolder(folder):
  178.     global _curfolder
  179.     warnings.warn('macfs.StandardGetFile and friends are deprecated, use EasyDialogs.AskFileForOpen', DeprecationWarning, stacklevel = 2)
  180.     if _curfolder:
  181.         rv = FSSpec(_curfolder)
  182.     else:
  183.         rv = None
  184.     _curfolder = folder
  185.     return rv
  186.  
  187.  
  188. def _handleSetFolder():
  189.     global _curfolder
  190.     rv = _curfolder
  191.     _curfolder = None
  192.     return rv
  193.  
  194.  
  195. def GetDirectory(prompt = None):
  196.     '''Ask the user to select a folder. Optionally you can give a prompt.'''
  197.     import EasyDialogs
  198.     warnings.warn('macfs.StandardGetFile and friends are deprecated, use EasyDialogs.AskFileForOpen', DeprecationWarning, stacklevel = 2)
  199.     fss = EasyDialogs.AskFolder(message = prompt, wanted = FSSpec, defaultLocation = _handleSetFolder())
  200.     return (fss, not (fss is None))
  201.  
  202.